
int data = 3;
int latch = 4;
int clock = 5;

void setup()
{
  pinMode(data, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(clock, OUTPUT);
  // Open serial port
  Serial.begin(9600);
}

void loop()
{
    byte ledValue;
    
    if (Serial.available() > 0)
    {
      ledValue = Serial.read();
      updateLEDs(ledValue);
    }
}

void updateLEDs(int value)
{
  digitalWrite (latch, LOW);
  shiftOut(data, clock, MSBFIRST, value);
  digitalWrite (latch, HIGH);
}
